@extends('web.frame_layout')
<?php $parent_menu = "会员管理"; $menu_selected = "会员推荐关系图";?>

@section('head')
    <link rel="stylesheet" href="{{ asset('zTree/css/zTreeStyle/zTreeStyle.css') }}" type="text/css">
    {{--<link rel="stylesheet" href="{{asset('web/css/layui.css')}}">--}}
    <link rel="stylesheet" href="{{asset('web/css/recommend-nexus.css')}}">
@endsection

@section('content')

    <div class="m-right-nr">
        <div>
            <h2><span>{{$menu_selected}}</span></h2>
        </div>
        <div class="tjgx">
            <h3>
                <form id="search" action="{{route('web.node.zTree')}}" method="get">
                    <input type="text" id="name" name="name" placeholder="请输入用户名搜索">
                    <button class="searchBtn" onclick="$('#search').submit()">搜索</button>
                </form>

            </h3>
            <div class="zTreeDemoBackground left">
                <ul id="treeDemo" class="ztree"></ul>
            </div>
        </div>
    </div>

@endsection

@section('footer')
    <script type="text/javascript" src="{{ asset('zTree/js/jquery.ztree.core.js') }}"></script>
    <script type="text/javascript">
        var setting = {
            data: {
                key: {
                    title: "t"
                },
                simpleData: {
                    enable: true
                }
            }
        };

        var str = '{!!  $user !!}';
        var obj = eval(str);
        var zNodes = [];

        for (var i in obj) {
            zNodes.push({
                id: obj[i].id,
                pId: obj[i].pid,
                name: obj[i].username + '（' + obj[i].realname + '）',
                t: 'ID: ' + obj[i].id,
                icon: "{{asset('admin/imgs/default_head.jpg')}}",
                open: true,
            });
        }

        $(document).ready(function () {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
    </script>
@endsection